package 力扣._73_矩阵置零;

import java.util.HashSet;
import java.util.Set;

public class Solution {
    public void setZeroes(int[][] matrix) {
        Set<int[]> set = new HashSet<>();
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if (matrix[i][j] == 0)
                    set.add(new int[]{i, j});
            }
        }
        for (int[] s : set) {
            int i = s[0], j = s[1];
            //列置零
            for (int k = 0; k < matrix.length; k++)
                matrix[k][j] = 0;
            //行置零
            for (int k = 0; k < matrix[0].length; k++)
                matrix[i][k] = 0;
        }
    }
}
